package ru.evga.inse.server.gwt.admin.client.menu.dict.city;

import ru.evga.gwt.lib.common.client.actitvity.AbstractEntityListActivity;
import ru.evga.inse.server.gwt.admin.client.IAdminAppFactory;
import ru.evga.inse.server.gwt.common.client.domain.dict.CityDto;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Window;


public class CityListActivity
    extends AbstractEntityListActivity<CityDto>
{
    private final IAdminAppFactory factory;
    private CityListView view;

    public CityListActivity(IAdminAppFactory factory)
    {
        super(factory.getViewFactory().getCityListView());
        view = factory.getViewFactory().getCityListView();
        this.factory = factory;
    }

    public void onEditClicked(CityDto item)
    {
        CityEditDialog dialog = new CityEditDialog(item, this);
        dialog.setTitle("Edit City");
        dialog.open();
    }

    public void onShowDetails(CityDto record)
    {
        Window.alert("onShowDetails");
    }

    public void onCreateClicked()
    {
        CityEditDialog dialog = new CityEditDialog(CityDto.createEmptyCityDto(), this);
        dialog.setTitle("Edit City");
        dialog.open();
    }

    public void onSelected(CityDto item)
    {
    }

    @Override
    protected String getEntityName()
    {
        return "city";
    }

    @Override
    protected JavaScriptObject getEntityRangeFilter()
    {
        return view.getCityFilterObject();
    }
}
